#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require "#{LKP_SRC}/lib/string_ext"
require "#{LKP_SRC}/lib/tests/stats"

stats = LKP::Stats.new

while (line = $stdin.gets)
  line = line.resolve_invalid_bytes
  case line
  when / (\(\d*\/\d*\))(.*):(.*):  (\w+)(.*)/
    test_file = $2.strip
    test_content = $3.downcase
    test_status = $4.downcase
    stats.add_test_result line, "#{test_file}_#{test_content}", test_status
  when /^(ignored_by_lkp): (.*)/
    stats.add_test_result line, $2, $1
  end
end

stats.dump
